package com.jincheng.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.os.Environment;

public class NetUtil {

	private static String url = "http://www.ajjct.com/api/index.php";

	public static String stream2File(String content) throws Exception {
		HttpClient client = new DefaultHttpClient();
		HttpPost post = new HttpPost(url);
		HttpResponse response = client.execute(post);
		if (response.getStatusLine().getStatusCode() == 200) {
			String result = EntityUtils.toString(response.getEntity(), "UTF-8");
			System.out.println(result);
			return result;
		}else{
			return "";
		}
		/*
		 * InputStream is = response.getEntity().getContent();
		 * 
		 * File file = new
		 * File(Environment.getExternalStorageDirectory(),"/anjie.xml");
		 * FileOutputStream out = new FileOutputStream(file); int len = 0;
		 * byte[] buffer = new byte[1024]; while((len = is.read(buffer)) != -1){
		 * out.write(buffer, 0, len); } out.flush(); out.close(); is.close();
		 */
	}

}
